package localwrap

import (
	"github.com/RocksonZeta/logger"
	"github.com/RocksonZeta/wrap/mysqlwrap"
	"github.com/RocksonZeta/wrap/redised"
	"github.com/RocksonZeta/wrap/rediswrap"
	"github.com/RocksonZeta/wrap/wraps"
)

func GetRedisedMysql() *redised.RedisedMysql {
	return &redised.RedisedMysql{
		Redis: wraps.GetRedisUrl(Config.Redis),
		Mysql: wraps.GetMysqlUrl(Config.Mysql),
		KeyFn: redised.DefaultKeyFn,
		KVFn:  redised.DefaultKVFn,
		Ttl:   Config.Dao.CacheTtl,
	}
}

var rootLogger *logger.FileLogger

func GetLogger() logger.FileLogger {
	if nil == rootLogger {
		logger := logger.NewLogger(Config.Log.Service)
		rootLogger = &logger
	}
	return *rootLogger
}

func GetRedis() *rediswrap.Redis {
	return wraps.GetRedisUrl(Config.Redis)
}
func GetMysql() *mysqlwrap.Mysql {
	return wraps.GetMysqlUrl(Config.Mysql)
}
